# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.DNS.V1.Model.RRSetRoutingPolicyPrimaryBackupPolicy do
  @moduledoc """
  Configures a RRSetRoutingPolicy such that all queries are responded with the primary_targets if they are healthy. And if all of them are unhealthy, then we fallback to a geo localized policy.

  ## Attributes

  *   `backupGeoTargets` (*type:* `GoogleApi.DNS.V1.Model.RRSetRoutingPolicyGeoPolicy.t`, *default:* `nil`) - Backup targets provide a regional failover policy for the otherwise global primary targets. If serving state is set to `BACKUP`, this policy essentially becomes a geo routing policy.
  *   `kind` (*type:* `String.t`, *default:* `dns#rRSetRoutingPolicyPrimaryBackupPolicy`) - 
  *   `primaryTargets` (*type:* `GoogleApi.DNS.V1.Model.RRSetRoutingPolicyHealthCheckTargets.t`, *default:* `nil`) - Endpoints that are health checked before making the routing decision. Unhealthy endpoints are omitted from the results. If all endpoints are unhealthy, we serve a response based on the `backup_geo_targets`.
  *   `trickleTraffic` (*type:* `float()`, *default:* `nil`) - When serving state is `PRIMARY`, this field provides the option of sending a small percentage of the traffic to the backup targets.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :backupGeoTargets => GoogleApi.DNS.V1.Model.RRSetRoutingPolicyGeoPolicy.t() | nil,
          :kind => String.t() | nil,
          :primaryTargets =>
            GoogleApi.DNS.V1.Model.RRSetRoutingPolicyHealthCheckTargets.t() | nil,
          :trickleTraffic => float() | nil
        }

  field(:backupGeoTargets, as: GoogleApi.DNS.V1.Model.RRSetRoutingPolicyGeoPolicy)
  field(:kind)
  field(:primaryTargets, as: GoogleApi.DNS.V1.Model.RRSetRoutingPolicyHealthCheckTargets)
  field(:trickleTraffic)
end

defimpl Poison.Decoder, for: GoogleApi.DNS.V1.Model.RRSetRoutingPolicyPrimaryBackupPolicy do
  def decode(value, options) do
    GoogleApi.DNS.V1.Model.RRSetRoutingPolicyPrimaryBackupPolicy.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.DNS.V1.Model.RRSetRoutingPolicyPrimaryBackupPolicy do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
